package hotciv.common;

import hotciv.framework.City;
import hotciv.framework.Game;
import hotciv.framework.GameObserver;
import hotciv.framework.Player;
import hotciv.framework.Position;
import hotciv.framework.Tile;
import hotciv.framework.Unit;

public class GameLogger implements Game {
	private Game game;
	
	public GameLogger(Game game) {
		this.game = game;
	}
	
	public Game getGame() {
		return game;
	}
	
	private void writeToLog(String action) {
		System.out.println(game.getPlayerInTurn()+": "+action);
	}
	
	@Override
	public Tile getTileAt(Position p) {
		return game.getTileAt(p);
	}

	@Override
	public Unit getUnitAt(Position p) {
		return game.getUnitAt(p);
	}

	@Override
	public City getCityAt(Position p) {
		return game.getCityAt(p);
	}

	@Override
	public Player getPlayerInTurn() {
		return game.getPlayerInTurn();
	}

	@Override
	public Player getWinner() {
		return game.getWinner();
	}

	@Override
	public int getAge() {
		return game.getAge();
	}

	@Override
	public boolean moveUnit(Position from, Position to) {
		boolean canMove = game.moveUnit(from, to);
		writeToLog( (canMove?"legal":"illegal")+" move of unit from: "+from+" to: "+to);
		return canMove;
	}

	@Override
	public void endOfTurn() {
		writeToLog("ends turn");
		game.endOfTurn();
	}

	@Override
	public void changeWorkForceFocusInCityAt(Position p, String balance) {
		writeToLog("changes workforce focus to: "+balance+" in city at: "+p);
		game.changeWorkForceFocusInCityAt(p, balance);
	}

	@Override
	public void changeProductionInCityAt(Position p, String unitType) {
		writeToLog("changes production focus to: "+unitType+" in city at: "+p);
		game.changeProductionInCityAt(p, unitType);
	}

	@Override
	public void performUnitActionAt(Position p) {
		writeToLog("performs unit action at "+p);
		game.performUnitActionAt(p);
		
	}

	@Override
	public void addObserver( GameObserver observer )
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setTileFocus(Position p) {
		// TODO Auto-generated method stub
		
	}

}
